package com.travelsmart.client.apresentacao.widget;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class FormImagePopupPanel extends Composite{
	
	public FormImagePopupPanel(String big_imagem){
		super();
	    HTML imageFull = new HTML("<img src='"+ big_imagem + "'/>");
	    final PopupPanel imagePopup = new PopupPanel(true);
	    imagePopup.setAnimationEnabled(true);
	    imagePopup.ensureDebugId("cwBasicPopup-imagePopup");
	    imagePopup.setWidget(imageFull);
	    imageFull.addClickHandler(new ClickHandler() {
	      public void onClick(ClickEvent event) {
	        imagePopup.hide();
	      }
	    });
	    HTML imageThumb = new HTML("<img src='"+ big_imagem.replaceAll("_b.jpg", "_t.jpg") + "'/>");
	    imageThumb.ensureDebugId("cwBasicPopup-thumb");
	    imageThumb.addStyleName("cw-BasicPopup-thumb");
	    imageThumb.addClickHandler(new ClickHandler() {
	      public void onClick(ClickEvent event) {
	        imagePopup.center();
	      }
	    });
	    VerticalPanel vPanel = new VerticalPanel();
	    vPanel.add(imageThumb);
	    initWidget(vPanel);
	}

}
